//
//  WorkNoteListViewController.m
//  DuckAndDoc
//
//  Created by 蓝水软件 on 2017/5/5.
//  Copyright © 2017年 苏州蓝水有限公司. All rights reserved.
//

#import "WorkNoteListViewController.h"
#import "TitleOfDayTableViewCell.h"
#import "workNoteDaymodel.h"
#import "AddWorkNoteViewController.h"

@interface WorkNoteListViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) IBOutlet UITableView *workNoteTable;
@property (nonatomic,strong) UIButton *addButton;
@property (nonatomic,strong) workNoteDaymodel *testModel;
@end

@implementation WorkNoteListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUI];
}

- (void)setUI{
    self.title = LocalizedStrFrom(@"workNoteTitle");
    self.workNoteTable.delegate = self;
    self.workNoteTable.dataSource = self;
    self.workNoteTable.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.addButton];
    [self.addButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.bottom.mas_equalTo(-24);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
}

#pragma mark -- tableDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    TitleOfDayTableViewCell *cell = [TitleOfDayTableViewCell cellWithTable:tableView];
    [cell cellWithModel:self.testModel];
    return cell;
}

#pragma mark -- lazy load
-(workNoteDaymodel *)testModel{
    if (_testModel == nil) {
        _testModel = [workNoteDaymodel new];
        _testModel.date = @"2017-05-09";
        _testModel.unfinishedNum = @"23";
    }
    return _testModel;
}

- (UIButton *)addButton{
    if (_addButton == nil) {
        _addButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addButton setImage:img(@"add") forState:UIControlStateNormal];
         @weakify(self);
        [[_addButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self);
            AddWorkNoteViewController *addWorkController = [AddWorkNoteViewController new];
            [self.navigationController pushViewController:addWorkController animated:YES];
        }];
        
    }
    return _addButton;
}
@end
